package com.weasel.weixin.commons.message.builder;

import com.weasel.weixin.commons.message.bean.WeiXinPostCommonXmlAnswerImageMessage;

/**
 * Created by Dylan on 2015/10/12.
 */
public class WeixinPostCommonXmlAnswerImageMessageBuilder extends AbstractWeixinPostCommonXmlAnswerMessageBuilder<WeixinPostCommonXmlAnswerImageMessageBuilder,WeiXinPostCommonXmlAnswerImageMessage>{


    public WeixinPostCommonXmlAnswerImageMessageBuilder() {
        super(new WeiXinPostCommonXmlAnswerImageMessage());
    }


    public WeixinPostXmlAnswerImageBodyMessageBuilder image(){

        return new WeixinPostXmlAnswerImageBodyMessageBuilder(this);
    }

    public static class WeixinPostXmlAnswerImageBodyMessageBuilder{

        private WeixinPostCommonXmlAnswerImageMessageBuilder parent;

        private WeiXinPostCommonXmlAnswerImageMessage.ImageBody body = new WeiXinPostCommonXmlAnswerImageMessage.ImageBody();

        public WeixinPostXmlAnswerImageBodyMessageBuilder(){
        }

        public WeixinPostXmlAnswerImageBodyMessageBuilder(WeixinPostCommonXmlAnswerImageMessageBuilder _parent){

            this.parent = _parent;
        }

        public WeixinPostXmlAnswerImageBodyMessageBuilder mediaId(String mediaId){

            body.setMediaId(mediaId);
            return this;
        }

        public WeixinPostCommonXmlAnswerImageMessageBuilder end(){

            if(null == parent){
                throw new RuntimeException("请调用带参的构造方法，并传递WeixinPostCommonXmlAnswerImageMessageBuilder参数，否则请调用build方法");
            }
            ((WeiXinPostCommonXmlAnswerImageMessage)parent.message).setImage(build());
            return parent;
        }

        public WeiXinPostCommonXmlAnswerImageMessage.ImageBody build(){

            return body;
        }

    }
}
